1. Field of the Invention
The invention relates to an apparatus for modifying data stored in a random access memory, the data corresponding to one or more rows of pixels of a stored image, the memory comprising a first memory (colour RAM) for storing a colour value for each pixel and a second memory (z-RAM) for storing a depth (z) value for each pixel, the apparatus comprising:
- means for receiving input data defining addresses, colour values and depth (z) values for a series of pixels; PA1 - means for selecting each pixel in the series in turn and synchronously generating successive addresses, input colour values and input z-values; PA1 - means for applying the address of each selected pixel to address inputs of the z-RAM and colour-RAM; PA1 - means for reading from the z-RAM the current z-value for each selected pixel; PA1 - means for comparing the current z-value with the input z-value for each selected pixel; PA1 - means for writing the input z-values for each selected pixel into the addressed location of the z-RAM and for writing the input colour values into the addressed location of the colour-RAM, said means being responsive to an output of the comparing means so as to enable the writing of the input colour value into the colour-RAM and the input z-value into the z-RAM, to define a new colour value and a new z-value for a given selected pixel if the input z-value represents a lesser depth than the current z-value for that pixel.
The invention further relates to an electronic graphics system including such an apparatus.
2. Related Art
An apparatus as set forth in the opening paragraph is known in the art of electronic graphics generation and is used for performing hidden surface removal (HSR) for the two-dimensional display of data representing three-dimensional objects. The apparatus employs a `depth-buffer` or `z-buffer` algorithm, as described for example in `Principles of Interactive Computer Graphics' by W. M. Newman and R. F. Sproull, at pages 369 to 371.
Three-dimensional models are created and stored, for example in a computer, and then scan-converted into two-dimensional colour information for storage in a random access memory or frame buffer. Once all the objects to be shown have been converted, the frame buffer (colour RAM) is read out according to a raster-scanning pattern, to drive a display device, such as a cathode ray tube (CRT). Unless the three-dimensional objects are converted and stored in a strict order of decreasing depth into the scene to be represented, hidden surface removal (HSR) is required to ensure that objects in the foreground are not overwritten in the colour-RAM by objects which are meant to be in the background but are converted later.
In z-buffer HSR, an additional memory (z-RAM) is provided to store current depth values for every pixel stored in the colour-RAM, so that incoming object data can be compared to see if it is in front of (visible) or behind (not visible) any objects already plotted at that pixel location. Only if the incoming object is visible will the old colour data be overwritten, and of course the input depth value becomes the new current depth value.
Such an algorithm can of course be implemented in computer software, but for high speed operation it is generally necesary to perform the HSR in hardware, at the time of scan-conversion.
Apart from the extra memory required for the z-buffer (which is, in any case, a diminishing burden with new low-cost high-density semiconductor memory chips) z-buffer HSR has the disadvantage of slowing down the rate at which pixel data can be written. This is because, rather than just writing each pixel colour value as it is supplied, the HSR hardware must (i) read the current z-value, (ii) compare the z-values and only then (iii) conditionally write the new z-value and the new colour value. Each memory cycle (i) and (iii) takes a finite time, as does the comparison (ii).